package com.kakarote.crm9.erp.ding.service;

import com.jfinal.plugin.activerecord.Db;
import com.kakarote.crm9.erp.admin.entity.AdminUser;
import com.kakarote.crm9.erp.ding.entity.DingAlluser;
import com.kakarote.crm9.utils.BaseUtil;
import com.kakarote.crm9.utils.R;

import java.util.List;

public class DingAllUserService {

    public Integer getSum(String userid){
        Integer ss = Db.queryInt(Db.getSql("ding.ding.getSum"),userid);
        return ss;
    }
    public List<DingAlluser> getAll(){
        List<DingAlluser> list = DingAlluser.dao.findAll();
        return list;
    }

    public R upAll(DingAlluser dingAlluser) {

        Integer update = Db.update("update ding_alluser set `name` = ?,mobile = ?,position = ?,jobnumber = ?,unionid = ? where user_id = ?",dingAlluser.getName() , dingAlluser.getMobile(),dingAlluser.getPosition(),dingAlluser.getJobnumber(),dingAlluser.getUnionid(),dingAlluser.getUserId());

        return update > 0 ? R.ok() : R.error();
    }
    public DingAlluser getUnionid(String unionid){
        DingAlluser dingAlluser = DingAlluser.dao.findFirst(Db.getSql("ding.ding.finduser"),unionid);
        return dingAlluser;
    }
    public Integer findMobiles(String mobile){
        Integer sd = Db.queryInt(Db.getSql("ding.ding.findMobiles"),mobile);
        return sd;
    }

}
